module.exports = {
  inserted: function (el, binding, vnode) {
    const odiv = el; // 获取当前元素
    let dragFlag = false;
    el.style.position = "absolute"; // 这一步一定不要忘记
    let x, y;
    odiv.style.cursor = "move";
    odiv.onmousedown = (e) => {
      e = e || window.event; //解决ie兼容问题
      x = e.clientX - odiv.offsetLeft;
      y = e.clientY - odiv.offsetTop;
      dragFlag = true;
      document.onmousemove = (e) => {
        if (dragFlag == true) {
          e = e || window.event;
          odiv.style.left = e.clientX - x + "px";
          odiv.style.top = e.clientY - y + "px";
        }
      };
      document.onmouseup = (e) => {
        document.onmousemove = null;
        document.onmouseup = null;
        dragFlag = false;
      };
    };
  },
};
